求救``谁能把这个C++程序补充完整

来源:百度知道 编辑:UC知道 时间:2024/06/04 03:10:24
一个坐标系中 有 A(Xa Ya) B(Xb Yb) 2个点 A B 2个点的数值要求从txt 文档中读取( AB 数量随意) 求出所有 A B 2点间的距离L 输出显示在屏幕上 然后任意输入一个值T 把这些距离与T进行比较 如果有距离小于T值 输出满足这个条件的A, B 2点的坐标

只写了一半 后面的不知道怎么写了 快交了 很着急`

#include <iostream.h>
#include <math.h>
#include <fstream.h>

double x1,x2,y1,y2,L;

int main()
{

double T;

ifstream input;
input.open("a.txt");

while (input>>x1>>y2>>y1>>y2)
{
L = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

cout.setf(ios::fixed);
cout.precision(2);
cout<<x1<<'\t'<<y1<<'\t'<<x2<<'\t'<<y2<<endl;
cout<<L<<endl;
}

cout<<"input a number:\n";
cin>>T;
你什么意思 什么叫无药可救了 我是新手我当然很多都不懂了

#include <iostream.h>
#include <math.h>
#include <fstream.h>
#define MAX 100
struct Distance //定义一个结构体吧,不然的话,你说输入的坐标放在哪呢
{
double x1;
double x2;
double y1;
double y2;
double L;
}distance[MAX];

int main()
{

double T;
int i = 0;
int j;

ifstream input;
input.open("a.txt");

while (input>>distance[i].x1>>distance[i].x2>>distance[i].y1>>distance[i].y2)
{
distance[i].L = sqrt((distance[i].x2-distance[i].x1)*(distance[i].x2-distance[i].x1)+(distance[i].y2-distance[i].y1)*(distance[i].y2-distance[i].y1));

cout.setf(ios::fixed);
cout.precision(2);
cout<<distance[i].x1<<'\t'<<distance[i].y1<<'\t'<<distance[i].x2<<'\t'<<distance[i].y2<<endl;
cout<<distance[i].L<<